package top.burning.confidant.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;


@Aspect
@Component
public class LogAspect {
    private static final Logger  LOGGER=LoggerFactory.getLogger(LogAspect.class);
    @Before("execution(* top.burning.confidant.controller.*Contorller.*(..))")
    public void beforeMethod(JoinPoint joinPoint){
        StringBuffer stringBuffer=new StringBuffer();
        for(Object arg:joinPoint.getArgs()){
            stringBuffer.append("arg"+arg.toString()+"|");
        }
        LOGGER.info("before method"+ stringBuffer.toString());
    }

    @After("execution (* top.burning.confidant.controller.*Contorller.*(..))")
    public void  afterMetod(JoinPoint joinPoint){
        StringBuffer stringBuffer=new StringBuffer();
        for(Object arg:joinPoint.getArgs()){
            stringBuffer.append("arg:"+arg.toString()+"|");
        }
        LOGGER.info("after method:");
    }
}